﻿using System;
using System.Collections.Generic;
using Microsoft.EntityFrameworkCore;
using TL_Cloud.Core.Entities;

namespace TL_Cloud.Models.BookShop
{
    public partial class Bk_Comment : BaseEntity
    {
        public string CommentId { get; set; }
        public string BookId { get; set; }
        
        public string CommentUserId { get; set; }
        public string Content { get; set; }
        public string CommentUserName { get; set; }

        public virtual Bk_Info bookInfo { get; set; }

        public override void Create(string userId,string userName)
        {
            this.CommentId = Guid.NewGuid().ToString();
            this.CreateDate = DateTime.Now;
            this.CommentUserId = userId;
            this.CommentUserName = userName;
        }

        public override void Mapping(ModelBuilder modelBuilder)
        {
            modelBuilder.Entity<Bk_Comment>(entity =>
            {
                entity.HasKey(e => e.CommentId);

                entity.ToTable("BK_Comment");

                entity.Property(e => e.CommentId)
                    .HasMaxLength(50)
                    .IsUnicode(false)
                    .ValueGeneratedNever();

                entity.Property(e => e.BookId)
                    .HasMaxLength(50)
                    .IsUnicode(false);
                 

                entity.Property(e => e.Content).HasColumnType("text");

                entity.Property(e => e.CreateDate).HasColumnType("datetime");

                entity.Property(e => e.CommentUserId)
                    .HasMaxLength(50)
                    .IsUnicode(false);
                entity.Property(e => e.CommentUserName)
                  .HasMaxLength(50)
                  .IsUnicode(false);
            });
        }
    }
}
